package com.sh.healthtv.view;


import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.sh.healthtv.R;

public class NewToast extends Toast {

	private static Context mContext;
	private NewToast mNewToast;
	private NewToast(Context context) {
		super(context);
		this.mContext = context;
	}

	public NewToast getInstance(Context context){
		if(mNewToast == null){
			mNewToast = new NewToast(context);
		}
		return mNewToast;
	}
	
	public static Toast makeText(Context context, CharSequence text, int duration) {  
		if(context == null){
			return null;
		}
        Toast result = new Toast(context);  
          
        //获取LayoutInflater对象  
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);   
        //由layout文件创建一个View对象  
        View layout = inflater.inflate(R.layout.newtoast, null);  
          
        //实例化ImageView和TextView对象  
        TextView textView = (TextView) layout.findViewById(R.id.toast_text);
          
        textView.setText(text);  
//        textView.setTextSize(size);
        result.setView(layout);  
        result.setGravity(Gravity.CENTER_VERTICAL, 0, 0);  
        result.setDuration(duration);  
          
        return result;  
    } 
}
